<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="common/head :: htmlhead">

<body>
<link rel="stylesheet" th:href="@{/static/plugins/sweetalert.css}">
<script th:src="@{/static/plugins/sweetalert.min.js}"></script>
<style>
    .layui-form-select dl {
        z-index: 9999999999999999999999;
    }

</style>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">内容详情</div>
                <div class="layui-card-body">
                    <div class="layui-form">
                        <div class="layui-row layui-col-space10 layui-form-item">
                            <div class="layui-col-lg12">
                                <label class="layui-form-label">文章标题</label>
                                <div class="layui-input-block">
                                    <input class="layui-input" readonly th:value="${title}">
                                </div>
                            </div>
                        </div>
                        <div class="layui-row layui-col-space10 layui-form-item">
                            <div class="layui-col-lg12">
                                <label class="layui-form-label">所属类别</label>
                                <div class="layui-input-block">
                                    <input class="layui-input" readonly th:value="${type}">
                                </div>
                            </div>
                        </div>
                        <div class="layui-row layui-col-space10 layui-form-item">
                            <div class="layui-col-lg12">
                                <label class="layui-form-label">文章内容</label>
                                <div class="layui-input-block">
                                    <div th:utext="${context}"></div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button th:if="${show} ne 'no'" type="button" class="layui-btn" onClick="publish()">发布
                                </button>
                                <button type="button" class="layui-btn layui-btn-primary" onClick="history.go(-1);">返回
                                </button>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
</div>
<script th:inline="javascript" type="text/javascript">
    layui.use(['element', 'form'], function () {
        var element = layui.element
            , form = layui.form
    });
    // var show = [[${show}]];
    // if (show === "no") {
    //     $("#showbtn").attr("style","display:none;");
    // }
    function publish() {
        layer.confirm('确定发布？', function (index) {
            layer.close(index);
            $.ajax({
                url: "/postNews",
                async: false,
                type: "POST",
                dataType: "text",
                data: {"id": [[${id}]]},
                success: function (aa) {
                    if (aa === "error") {
                        layer.open({
                            title: '信息'
                            , content: '发布失败！'
                            , end: function () {
                                location.reload();
                            }
                        });
                    } else if (aa === "success") {
                        layer.open({
                            title: '信息'
                            , content: '发布成功！'
                            , end: function () {
                                history.go(-1);
                            }
                        });
                    }
                }
            })
        });
    }
</script>
</body>
